<?php
// 辅助函数文件

/**
 * 例子: posts.index   =>  posts-index
 * @return string|string[]
 */
function route_class() {
    return str_replace('.', '-', \Illuminate\Support\Facades\Route::currentRouteName());
}

function dda(...$vars) {
    foreach ($vars as $v) {
        if (is_object($v)) {
            \Symfony\Component\VarDumper\VarDumper::dump($v->toArray());
        } else {
            \Symfony\Component\VarDumper\VarDumper::dump($v);
        }
    }
    exit(1);
}

function ngrok_url($routeName, $parameters=[]) {
    // 开发环境, 并配置NGROK_URL
    if (app()->environment('local') && $url = config('app.ngrok_url')) {
        return $url.route($routeName, $parameters, false);
    }

    return route($routeName, $parameters);
}